package com.lsp.base.empty;

import android.support.annotation.NonNull;
import android.view.View;

/**
 * @author com.lsp.ibxs
 * @created 16/11/25 11:13
 */
public class EmptyLayoutDelegateImpl implements EmptyLayoutDelegate {

  @Override public void setLoadDataSucced(@NonNull EmptyLayout emptyLayout) {
    emptyLayout.setErrorType(EmptyLayout.HIDE_LAYOUT);
  }

  @Override public void setLoadDataError(@NonNull EmptyLayout emptyLayout,
      View.OnClickListener mOnClickListener) {
    emptyLayout.setErrorType(EmptyLayout.NETWORK_ERROR);
    if (null != mOnClickListener) {
      emptyLayout.setButtonClickListener(mOnClickListener);
    }
  }

  @Override
  public void setNoData(@NonNull EmptyLayout emptyLayout, View.OnClickListener mOnClickListener) {
    emptyLayout.setErrorType(EmptyLayout.NODATA);
    if (null != mOnClickListener) {
      emptyLayout.setButtonClickListener(mOnClickListener);
    }
  }

  @Override public void setLoading(@NonNull EmptyLayout emptyLayout) {
    emptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
  }
}
